

//封装cookie

function setCookie(name,value,expires,path){
	
	var cookieText = encodeURIComponent(name) + '=' +encodeURIComponent(value);
	
	if(expires && expires instanceof Date){		//判断 expires 是否存在 存在则添加
		cookieText += '; expires=' + expires;
	}
	
	if(path){
		cookietext += '; path=' + path;			//判断 path 是否存在 存在则添加
	}
	
	document.cookie = cookieText;
	
	return decodeURIComponent(document.cookie);
}


//获取cookie

function getCookie(name){
	
	var str = decodeURIComponent(document.cookie);
	
	var arr = str.split('; ');
	
	for(var i = 0; i < arr.length; i++){
		var str1 = arr[i];
		var arr1 = str1.split('=');
		if(arr1[0] == name){
			return arr1[1];
		}
	}
	return ''
}

//删除
function removeCookie(name){
	document.cookie = encodeURIComponent(name) + '=; expires=' + new Date('2010-09-09');
	return decodeURIComponent(document.cookie);
}


